/**
 * 
 */
package recognition.processor;

import handwritten.character.HandWrittenCharacter;
import handwritten.gesture.MultiGesture;

import java.util.ArrayList;
import java.util.Hashtable;

import recognition.input.Input;

/**
 * @author tioz
 *
 */
public abstract class Processor {
	
	
	private ArrayList<Input<?>> dependentInputs;
	private Processor childs;
	/**
	 * 
	 */
	protected abstract boolean process(MultiGesture gest,HandWrittenCharacter target);
	
	@SuppressWarnings("unchecked")
	public boolean process(MultiGesture gest,HandWrittenCharacter target, Hashtable<Class<? extends Input<?>>,Input<?>> inputs){
		
		boolean ok = process(gest,target);
		
		if(ok){
			for(Input<?> i : dependentInputs)
				inputs.put((Class<? extends Input<?>>) i.getClass(), i.createInput(gest));
			
			childs.process(gest,target, inputs);
		}
		
		return ok;
	}
	
	
	public void addDependentInput(Input<?> i){
		dependentInputs.add(i);
	}
	
	public void addChild(Processor p){
		childs=p;
	}
	
	
}
